package com.lzlclass.http._async;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

@Component
@Async
public class EmailAsync {
    public Future<String> sendEmail() throws Exception{
        System.out.println("开始发送..");
        for(int  i = 0 ;i<10;i++){
            System.out.println((i+1)*10+"%");
            TimeUnit.SECONDS.sleep(1);
        }
        return new AsyncResult<>("发送成功");
    }

    public Future<String> sendEmail2() throws Exception{
        System.out.println("开始发送2..");
        for(int  i = 0 ;i<5;i++){
            System.out.println("------"+(i+1)*20+"% -----");
            TimeUnit.SECONDS.sleep(1);
        }
        return new AsyncResult<>("发送成功2");
    }







}
